<?php

(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
get_config_keytable("workclass_admin");
empty($do) && $do = 'list';
if($do == 'list') {
		if(getGP('view','P')=='save'){
		get_union_add();
		$idarr = getGP('id','P','array');
		$name = getGP('name','P','array');
		foreach ($idarr as $id) {
			if($name[$id]=='')$name[$id]='新工作流类别名称';
			$workclass_type = array(
				'title' => $name[$id]
			);
			update_db('workclass_type',$workclass_type, array('id' => $id));
		}
		$newname = '515158';
		foreach (getGP('newname','P','array') as $name) {
			$newname.=',,'.$name;
		}
		$newname=explode(',,',str_replace('515158,,','',$newname));
		if($newname!=''){
			for($i=0;$i<sizeof($newname);$i++){
				if($newname[$i]!='515158'){
					if($newname[$i]=='')$newname[$i]='新工作流类别名称';
					$workclass_type = array(
						'title' => $newname[$i],
						'uid' => $_USER->id,
						'unionid' => union_id
					);
					insert_db('workclass_type',$workclass_type);
					$id=$db->insert_id();
					$content=$newname[$i].get_inc_log(1).$_POST['type'].get_inc_log(1).$_USER->id;
					$title='添加工作流类别';
					get_oa_log_dbadd($id,$content,$title,35,$_USER->id);
				}
			}
		}
		
		if(publicunion=='515158.com'){
			union_mana_recache('workclass_type','id','id',union_id);
		}else{
			oa_mana_recache('workclass_type','id','id');
		}
		show_msg('工作流类别操作成功！', 'admin.php?ac='.$ac.'&fileurl='.$fileurl.'');
	}elseif(getGP('id','G')!=''){
		get_union_add();
		$db->query("DELETE FROM ".DB_TABLEPRE."workclass_type WHERE id = '".getGP('id','G')."' and unionid='".union_id."' ");
		$content=getGP('id','G').get_inc_log(1).$_USER->id;
		$title='删除工作流类别';
		get_oa_log_dbadd(getGP('id','G'),$content,$title,35,$_USER->id);
		show_msg('工作流类别删除成功！', 'admin.php?ac='.$ac.'&fileurl='.$fileurl.'');
	}else{
		get_config_keytable("workclass_admin");
		if (user_union_id!='') {
			$wheresqls = "  unionid='".user_union_id."'";
		}else{
			$wheresqls = "  unionid='".union_id."'";
		}
		$sql = "SELECT * FROM ".DB_TABLEPRE."workclass_type where ".$wheresqls."  ORDER BY id asc";
		$result = $db->fetch_all($sql);
		include_once('template/type.php');
	}
}

?>